package model

import (
	"qabx.net/safe-app-center/pkg/utils"
	"strconv"
)

type TblUserGatewayRel struct {
	UserId int `json:"user_id"`
	//AppId           int       `json:"app_id"`
	GatewayId int `json:"gateway_id"`
}

func (s *TblUserGatewayRel) GetUserIdByGateway() (int, error) {
	client, _ := utils.GetDbClient()
	//s.AppId = appId
	client.QueryParam = utils.QueryParam{
		Resource: s,
		Where:    "gateway_id = " + strconv.Itoa(s.GatewayId),
		Cols:     []string{"user_id"},
		Table:    "tbl_user_gateway_rel",
	}
	_, err := client.GetOne()
	return s.UserId, err

}
